package com.tsingning.modules.service.impl;

import com.tsingning.config.jwt.JwtUser;
import com.tsingning.modules.entity.SysUser;
import com.tsingning.modules.dao.SysUserMapper;
import com.tsingning.modules.service.SysUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 系统用户 服务实现类
 * </p>
 *
 * @author tsingning
 * @since 2019-11-04
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {

    @Autowired
    SysUserMapper sysUserMapper;

    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        SysUser user = sysUserMapper.findByUsername(s);
        return new JwtUser(user);
    }
}
